
import 'package:json_annotation/json_annotation.dart';
part 'video_model.g.dart';// 通过该part自动生成video_model.g.dart文件
@JsonSerializable()
class VideoModel {
  String title = '';
  String url = '';
  int playCount = 0;

  VideoModel(this.title, this.url, this.playCount);

  // 等同于使用java工厂设计模式
  // ignore: non_constant_identifier_names
//  factory VideoModel.fromJson(Map<String, dynamic> json) =>
//      VideoModel(json['title'], json['url'], json['playCount']);

  factory VideoModel.fromJson(Map<String, dynamic> json) => _$VideoModelFromJson(json);
  Map<String, dynamic> toJson(VideoModel model) => _$VideoModelToJson(model);
}
